package keeto.com.vn.bms.network.task;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.model.User.EditAdminModel;
import keeto.com.vn.bms.network.IBMSProtocol;
import keeto.com.vn.bms.network.request.GetSupportRequest;
import keeto.com.vn.bms.network.response.GetSupportResponse;
import keeto.com.vn.bms.utils.BMSListener;

public class TaskGetSupport extends AbstractTask{
	String authenKey;
	EditAdminModel admin;
	public TaskGetSupport(BMSListener listener, IBMSCore core,String authkey) {
		super(listener, core);
		// TODO Auto-generated constructor stub
		this.authenKey=authkey;
	}

	@Override
	public void run() throws ClientProtocolException, JSONException,
			IOException {
		// TODO Auto-generated method stub
		GetSupportRequest request= new GetSupportRequest();
		request.setAdmin(admin);
		request.setAuthenKey(authenKey);
		GetSupportResponse response= protocol.getAdminInfo(request);
		for(BMSListener mListener:listener){
			mListener.finishGetSuport(response.getReturnCode(),response.getResultMessage(),  response.getAdmin());
		} 
		
	}

	@Override
	public void timeoutCallback() {
		// TODO Auto-generated method stub
		for(BMSListener mListener:listener){
			mListener.finishGetSuport(IBMSProtocol.STATUS_CODE_GENERIC_FAIL_CONECTTION,"Failed", null);
		} 
	}

}
